home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / net / netUltraInt.h < prev   
C/C++ Source or Header  |  1991-07-26  |  25KB  |  679 lines

  1. /*
  2.  * netUltraInt.h --
  3.  *
  4.  *    Definitions for the UltraNet VME adapter.
  5.  *
  6.  * Copyright 1990 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  *
  15.  * $Header: /sprite/src/kernel/net/RCS/netUltraInt.h,v 1.4 91/07/26 17:13:21 jhh Exp $ SPRITE (Berkeley)
  16.  */
  17.  
  18. #ifndef _NETULTRAINT
  19. #define _NETULTRAINT
  20.  
  21. #include <netInt.h>
  22. #include <fs.h>
  23.  
  24. /*
  25.  * Defined constants:
  26.  *
  27.  * NET_ULTRA_CONTROL_REG_ADDR    Address of the Ultranet control
  28.  *                register.
  29.  * NET_ULTRA_INTERRUPT_PRIORITY The interrupt priority generated by the card.
  30.  *                This value derived from the Ultranet 
  31.  *                documentation
  32.  * NET_ULTRA_VME_REQUEST_LEVEL     The level of requests to the VME bus.
  33.  *                This value was derived from the Ultranet
  34.  *                source.
  35.  * NET_ULTRA_VME_ADDRESS_SPACE    Defines how the adapter uses the VME
  36.  *                address space in the following manner:
  37.  *                Bit 1 set => XRBs are in A32, A24 otherwise.
  38.  *                Bit 2 set => buffers are in A32, A24 otherwise.
  39.  *                Bit 3 set => Non-privileged access, 
  40.  *                    supervisor access otherwise.
  41.  *                Bit 4 set => block mode DMA, word access
  42.  *                    otherwise.
  43.  */
  44.  
  45. #ifdef sun3
  46. #define NET_ULTRA_CONTROL_REG_ADDR        0xffff7740
  47. #define NET_ULTRA_INTERRUPT_PRIORITY        3
  48. #define NET_ULTRA_VME_REQUEST_LEVEL        3
  49. #define NET_ULTRA_VME_ADDRESS_SPACE        0
  50. #define NET_ULTRA_MAP_THRESHOLD            1024
  51. #endif
  52.  
  53. #ifdef sun4
  54. #define NET_ULTRA_CONTROL_REG_ADDR        0xffff7740
  55. #define NET_ULTRA_INTERRUPT_PRIORITY        3
  56. #define NET_ULTRA_VME_REQUEST_LEVEL        3
  57. #define NET_ULTRA_VME_ADDRESS_SPACE        0
  58. #define NET_ULTRA_MAP_THRESHOLD            0
  59. #endif
  60.  
  61. typedef enum EventEnum {
  62.     TO_ADAPTER_FILLED,
  63.     INFO_NOT_PENDING,
  64.     PROCESS_XRB,
  65.     INTERRUPT,
  66.     SEND_REQ,
  67.     SEND_REQ_INFO,
  68.     START_DSND,
  69.     DSND,
  70.     DSND_WAIT,
  71.     DSND_STREAM,
  72. } EventEnum;
  73.  
  74. typedef struct NetUltraTraceInfo {
  75.     int                sequence;
  76.     EventEnum            event;
  77.     int                index;
  78.     struct NetUltraXRBInfo    *infoPtr;
  79.     Timer_Ticks            ticks;
  80. } NetUltraTraceInfo;
  81.  
  82. #define TRACE_SIZE 100
  83.  
  84. #define NEXT_TRACE(statePtr, ptrPtr) { \
  85.     NetUltraTraceInfo    *tmpPtr = (statePtr)->tracePtr;        \
  86.     *(ptrPtr) = tmpPtr;                        \
  87.     tmpPtr++;                            \
  88.     if (tmpPtr == &((statePtr)->traceBuffer[TRACE_SIZE])) {    \
  89.     tmpPtr = (statePtr)->traceBuffer;            \
  90.     }                                \
  91.     (statePtr)->tracePtr = tmpPtr;                \
  92.     (*(ptrPtr))->sequence = (statePtr)->traceSequence++;    \
  93. }
  94.  
  95. /*
  96.  * Structure to hold all state information associated with an Ultranet
  97.  * vme adapter.
  98.  */
  99.  
  100. typedef struct NetUltraState {
  101.     int            magic;        /* Useful for debugging. */
  102.     int            flags;        /* See below. */
  103.     volatile int     *intrReg;    /* Address of the adapter interrupt
  104.                      * register. */
  105.     volatile int     *resetReg;    /* Address of the reset register. */
  106.     struct NetUltraXRB    *firstToHostPtr;  /* First XRB in queue to host. */
  107.     struct NetUltraXRB    *nextToHostPtr;      /* Next XRB to be filled by
  108.                        * the adapter. */
  109.     struct NetUltraXRB    *lastToHostPtr;      /* Last XRB in queue to host. */
  110.     struct NetUltraXRB    *firstToAdapterPtr; /* First XRB in queue to adapter. */
  111.     struct NetUltraXRB    *nextToAdapterPtr;  /* Next XRB to be filled by host. */
  112.     struct NetUltraXRB    *lastToAdapterPtr;  /* Last XRB in queue to adapter. */
  113.     int            adapterVersion;    /* Version of adapter software. */
  114.     int            priority;    /* Interrupt priority. */
  115.     int            vector;        /* Interrupt vector. */
  116.     int            requestLevel;    /* VME bus request level. */
  117.     int            addressSpace;    /* Address space for queues and
  118.                      * buffers. */
  119.     int            maxReadPending;    /* Maximum pending datagram
  120.                      * reads on the interface. */
  121.     int            numReadPending;    /* Number of pending reads. */
  122.     int            readBufferSize;    /* Size of pending read buffers. */
  123.     int            maxWritePending; /* Maximum pending datagram writes.*/
  124.     int            numWritePending; /* Number of pending writes. */
  125.     Address        buffersDVMA;    /* DVMA buffers for pending reads
  126.                      * and writes. */
  127.     Address        buffers;    /* Address of DVMA buffers in kernel
  128.                      * address space. */
  129.     int            bufferSize;    /* Size of a DVMA buffer. */
  130.     int            numBuffers;    /* Number of DVMA buffers. */
  131.     List_Links        freeBufferListHdr; /* List of free DVMA buffers*/
  132.     List_Links        *freeBufferList; /* Ptr to list of free DVMA
  133.                       * buffers*/
  134.     Sync_Condition    bufferAvail; /* Condition to wait for a free
  135.                       * DVMA buffer. */
  136.     Sync_Condition    toAdapterAvail; /* Condition to wait for an XRB to
  137.                      * the adapter to become available. */
  138.     Boolean        queuesInit;    /* TRUE => XRB queues have been 
  139.                      * allocated. */
  140.     List_Links        pendingXRBInfoListHdr; /* List of info about pending 
  141.                         * XRBs.*/
  142.     List_Links        *pendingXRBInfoList;   /* Pointer to list of info about
  143.                         * pending XRBs. */
  144.     List_Links        freeXRBInfoListHdr;/* List of free XRB info 
  145.                         * structures. */
  146.     List_Links        *freeXRBInfoList;  /* Pointer to list of info about
  147.                         * pending XRBs. */
  148.     Net_Interface    *interPtr;       /* Interface structure associated
  149.                         * with this adapter. */
  150.     NetUltraTraceInfo    *tracePtr;
  151.     NetUltraTraceInfo    traceBuffer[TRACE_SIZE];
  152.     int            traceSequence;
  153.     Net_UltraStats    stats;
  154. } NetUltraState;
  155.  
  156. #define    NET_ULTRA_STATE_MAGIC    0x3a5a7a9a
  157.  
  158. /*
  159.  * Size of the XRB queues.
  160.  */
  161.  
  162. #define NET_ULTRA_NUM_TO_HOST        2    /* Number of XRBs to host. */
  163. #define NET_ULTRA_NUM_TO_ADAPTER    2    /* Number of XRBs to adapter. */
  164.  
  165. /*
  166.  * The following are defined for the flags field of the NetUltraState
  167.  * structure.
  168.  */
  169.  
  170. #define NET_ULTRA_STATE_EXIST    0x1    /* The adapter exists and its control
  171.                      * registers can be accessed. */
  172. #define NET_ULTRA_STATE_LOAD    0x2    /* The ucode is being downloaded. */
  173. #define    NET_ULTRA_STATE_GO    0x4    /* The go command has been sent. */
  174. #define NET_ULTRA_STATE_INIT    0x8    /* The init command has been sent. */
  175. #define NET_ULTRA_STATE_START  0x10    /* The start command has
  176.                      * been sent and the adapter is
  177.                      * online. */
  178. #define NET_ULTRA_STATE_EPROM    0x20    /* A reset command has just been
  179.                      * sent and the adapter is in
  180.                      * EPROM mode. */
  181. #define NET_ULTRA_STATE_ECHO    0x40    /* Received datagrams are sent
  182.                      * back to sender. */
  183. #define NET_ULTRA_STATE_DSND_TEST 0x80    /* A test of the datagram round-
  184.                      * trip time is in progress. */
  185. #define NET_ULTRA_STATE_SINK 0x100    /* Adapter will sink all received
  186.                      * packets. */
  187. #define NET_ULTRA_STATE_STATS 0x200    /* Collect statistics. */
  188. #define NET_ULTRA_STATE_NORMAL 0x400    /* Adapter is in normal state
  189.                      * (no tests being run). */
  190.  
  191.  
  192. /*
  193.  * When an XRB is sent to the adapter we queue up information about it
  194.  * that is used for processing the completion of the XRB.
  195.  */
  196.  
  197. #define NET_ULTRA_INFO_DATA_SIZE 128
  198.  
  199. typedef struct NetUltraXRBInfo {
  200.     List_Links        links;        /* Used to queue these up. */
  201.     int            flags;        /* See below. */
  202.     void        (*doneProc)();    /* Called from interrupt handler
  203.                      * when associated XRB is done. */
  204.     ClientData        doneData;    /* Data for doneProc. */
  205.     struct NetUltraXRB    *xrbPtr;    /* XRB associated with this 
  206.                      * structure. */
  207.     int            scatterLength;    /* Size of the scatter/gather array. */
  208.     Net_ScatterGather    *scatterPtr;    /* Ptr to scatter/gather array that
  209.                      * was passed to NetUltraSendReq. */
  210.     int            requestSize;    /* Size of the original request. */
  211.     union NetUltraRequest *requestPtr;    /* Ptr to the original request. */
  212.     Address        buffer;        /* Address of original buffer
  213.                      * if it was remapped. */
  214. } NetUltraXRBInfo;
  215.  
  216. /*
  217.  * Values for flag field of NetUltraXRBInfo.
  218.  */
  219. #define NET_ULTRA_INFO_PENDING    0x1    /* The XRB associated with the info
  220.                      * is pending completion. */
  221. #define NET_ULTRA_INFO_STD_BUFFER 0x2    /* Buffer is a 'standard' one, meaning
  222.                      * it is in the buffer area pointed
  223.                      * to by the state structure. */
  224. #define NET_ULTRA_INFO_REMAP    0x4    /* If set then the buffer was
  225.                      * remapped to make it contiguous
  226.                      * with the data. */
  227. /*
  228.  * DMA information that controls DMA to and from the adapter.
  229.  * This is part of the XRB.  The id and reference fields are used
  230.  * for virtual circuits.  The adapter may return an XRB that is
  231.  * a request to DMA more data, and the id and reference help the
  232.  * host to set things up.  We don't do virtual circuits yet.
  233.  *
  234.  * The offset field is of unknown use and should be set to 0.
  235.  */
  236.  
  237. typedef struct NetUltraDMAInfo {
  238.     unsigned char    cmd;        /* The DMA command.  See below. */
  239.     unsigned char    id;        /* Transaction id. Set to 0. */
  240.     unsigned short    reference;    /* VC reference. Set to 0. */
  241.     unsigned int    offset;        /* Buffer offset. Set to 0. */
  242.     NetUltraXRBInfo    *infoPtr;    /* Unused. */
  243.     unsigned int    length;        /* Length of the DMA (size of the
  244.                      * XRB minus this structure). */
  245. } NetUltraDMAInfo;
  246.  
  247. /* 
  248.  * Definitions for the cmd field of the NetUltraDMA structure. 
  249.  */
  250. #define NET_ULTRA_DMA_CMD_MASK    0xc0     /* Use this to mask off commands. */
  251. #define    NET_ULTRA_DMA_CMD_XRB    0x80    /* Only XRB is being DMA'ed. */
  252. #define NET_ULTRA_DMA_CMD_XRB_DATA 0xc0    /* An XRB and data is being DMA'ed. */
  253.  
  254. #define NET_ULTRA_DMA_CMD_FROM_ADAPTER 0x20 /* If this bit is set then the
  255.                       * DMA word is from the adapter
  256.                       * to the host. */
  257. /*
  258.  * The following commands are defined in the Ultranet source but appear
  259.  * to be useful only for channel-based adapters.
  260.  */
  261.  
  262. #define NET_ULTRA_DMA_CMD_DMA    0x00    /* Adapter asking for data. */
  263. #define    NET_ULTRA_DMA_CMD_DMA_DATA 0x40    /* Adapter sending data to host. */
  264.  
  265. /*
  266.  * Notes on above definitions.  If you are sending a datagram 
  267.  * set the cmd field to NET_ULTRA_DMA_CMD_XRB_DATA. If you want to receive
  268.  * a datagram set the cmd field to NET_ULTRA_DMA_CMD_XRB.  When the adapter
  269.  * finishes processing an XRB the cmd field will be set to
  270.  * (NET_ULTRA_DMA_CMD_XRB | NET_ULTRA_DMA_CMD_FROM_ADAPTER).  These notes
  271.  * only apply to the Ultranet VME adapter card. Any other setting of
  272.  * the cmd field consitutes an error for that card.
  273.  */
  274.  
  275.  
  276. /*
  277.  * Following the DMA information in the XRB is what is referred to as
  278.  * a "stdRB" in the Ultranet documentation. This is a bit confusing
  279.  * because an stdRB is nested in an XRB which is nested in an RB.
  280.  * We refer to the contents of an XRB as a "request" rather than a
  281.  * "request block" to avoid confusion.
  282.  *
  283.  * This structure is request information that is common to all requests.
  284.  */
  285.  
  286. typedef struct NetUltraRequestHdr {
  287.     unsigned char    cmd;        /* The request command. See below. */
  288.     unsigned char    status;        /* Status. See below. */
  289.     unsigned short    reference;    /* Reference to datagram or
  290.                      * virtual circuit. */
  291.     NetUltraXRBInfo    *infoPtr;    /* Info associated with the XRB. */
  292.     Address        buffer;        /* Data buffer in VME space. */
  293.     int            size;        /* Size of the data buffer. */
  294. } NetUltraRequestHdr;
  295.  
  296. /*
  297.  * Values for the cmd field of the NetUltraRequestHdr.
  298.  */
  299.  
  300. #define NET_ULTRA_START_REQ        (unsigned char ) (0x1)
  301. #define NET_ULTRA_STOP_REQ        (unsigned char ) (0x2)
  302. #define NET_ULTRA_NEW_START_REQ        (unsigned char ) (0x3)
  303. #define NET_ULTRA_DGRAM_SEND_REQ    (unsigned char ) (0x80 | 17)
  304. #define NET_ULTRA_DGRAM_RECV_REQ    (unsigned char ) (0x80 | 18)
  305.  
  306. /*
  307.  * Values for the status field of a NetUltraRequestHdr. These are set
  308.  * by the adapter after it processes a command. Some of them have
  309.  * unknown meaning. The first group (odd values) are considered 
  310.  * successful completion of the command.
  311.  */
  312.  
  313. #define NET_ULTRA_STATUS_OK                1
  314. #define NET_ULTRA_STATUS_OK_EOM                3
  315. #define NET_ULTRA_STATUS_OK_DECIDE            5
  316. #define NET_ULTRA_STATUS_OK_CLOSED            7
  317. #define NET_ULTRA_STATUS_OK_WITHDRAWN            9
  318. #define NET_ULTRA_STATUS_OK_REJECT_CONNECTION        11
  319. #define NET_ULTRA_STATUS_OK_CONN_REQ            13
  320. #define NET_ULTRA_STATUS_OK_CLOSING            15
  321. #define NET_ULTRA_STATUS_OK_TIMEDOUT            17
  322. #define NET_ULTRA_STATUS_OK_OUT_OF_SEQ            19
  323.  
  324. #define NET_ULTRA_STATUS_FAIL_INVALID_REQ        2
  325. #define NET_ULTRA_STATUS_FAIL_NO_RESOURCES        4
  326. #define NET_ULTRA_STATUS_FAIL_UNKNOWN_REF        6
  327. #define NET_ULTRA_STATUS_FAIL_BUF_TOO_SMALL        8
  328. #define NET_ULTRA_STATUS_FAIL_BUF_TOO_LONG        10
  329. #define NET_ULTRA_STATUS_FAIL_ILLEGAL_REQ        12
  330. #define NET_ULTRA_STATUS_FAIL_REM_ABORT            14
  331. #define NET_ULTRA_STATUS_FAIL_LOC_TIMEOUT        16
  332. #define NET_ULTRA_STATUS_FAIL_UNKNOWN_CONN_CLASS    18
  333. #define NET_ULTRA_STATUS_FAIL_DUP_REQ            20
  334. #define NET_ULTRA_STATUS_FAIL_CONN_REJECT        22
  335. #define NET_ULTRA_STATUS_FAIL_NEGOT_FAILED        24
  336. #define NET_ULTRA_STATUS_FAIL_ILLEGAL_ADDRESS        26
  337. #define NET_ULTRA_STATUS_FAIL_NETWORK_ERROR        28
  338. #define NET_ULTRA_STATUS_FAIL_PROTOCOL_ERROR        30
  339. #define NET_ULTRA_STATUS_FAIL_ILLEGAL_RB_LENGTH        32
  340. #define NET_ULTRA_STATUS_FAIL_UNKNOWN_SAP_ID        34
  341. #define NET_ULTRA_STATUS_FAIL_ZERO_RB_ID        36
  342. #define NET_ULTRA_STATUS_FAIL_ADAPTER_DOWN        38
  343.  
  344. /*
  345.  * The following are the formats for request block (RB) that are sent
  346.  * to the adapter. We only use a few of them.
  347.  */
  348.  
  349. /*
  350.  * The request format for a datagram request.  This structure has the
  351.  * same format as a Net_UltraHeader so the two can be interchanged.
  352.  */
  353.  
  354. typedef struct NetUltraDatagramRequest {
  355.     NetUltraRequestHdr    hdr;        /* Request header. */
  356.     Net_UltraTLAddress    remoteAddress;    /* Address of remote host. */
  357.     Net_UltraTLAddress    localAddress;    /* Address of local host. */
  358.     unsigned short    options;    /* Unused. */
  359.     unsigned short    quality;    /* Unused. */
  360.     unsigned int    pad3;
  361. } NetUltraDatagramRequest;
  362.  
  363. /*
  364.  * Define the number and pending reads and writes on an interface.
  365.  */
  366.  
  367. #define NET_ULTRA_PENDING_READS        NET_ULTRA_NUM_TO_HOST
  368. #define NET_ULTRA_PENDING_WRITES    NET_ULTRA_NUM_TO_ADAPTER    
  369.  
  370. /* 
  371.  * Request format for a start (NEW-START in Ultra doc) command.
  372.  */
  373.  
  374. typedef struct NetUltraStartRequest {
  375.     NetUltraRequestHdr    hdr;        /* Request header. */
  376.  
  377.     /* Host to adapter fields. */
  378.     unsigned short    sequence;    /* Sequence number. */
  379.     unsigned short    softwareRel;    /* Software release. */
  380.     unsigned long    flags;        /* See below. */
  381.     unsigned short    hostType;    /* Type of host. See below. */
  382.     unsigned short    hostOS;        /* Host operating system. See below. */
  383.     unsigned short    hostHW;        /* Host hardware.  See below. */
  384.     unsigned char    sendTimeout;    /* Send timeout in seconds. */
  385.     unsigned char    recvTimeout;    /* Recv timeout in seconds. */
  386.     unsigned char    beatPeriod;    /* Seconds between heartbeats
  387.                      * (0 = no heartbeats) */
  388.     unsigned char    hostMaxBytes;    /* Maximum packet size allowed by
  389.                      * host (as a power of 2). */
  390.     unsigned char    pad1[14];    /* Padding. */
  391.     unsigned char    netAddressSize;    /* sizeof(Net_Address).*/
  392.     unsigned char    netAddressBuf[sizeof(Net_Address)]; /* Net address 
  393.                      * (station address). */
  394.     unsigned char    pad2[15 - sizeof(Net_Address)]; /* Allow a
  395.                      * net address to grow. */
  396.     /* Adapter to host fields. */
  397.     unsigned short    ucodeRel;    /* Micro-code release */
  398.     unsigned short    adapterType;    /* Type of adapter. See below. */
  399.     unsigned short    adapterHW;    /* Adapter hardware info. See below. */
  400.     unsigned short    maxVC;        /* Maximum virtual circuits. */
  401.     unsigned char    maxRECV;    /* Maximum pending RECVs. */
  402.     unsigned char    maxDRCV;    /* Maximum pending DRCVs. */
  403.     unsigned char    maxERCV;    /* Maximum pending ERCVs. */
  404.     unsigned char    maxSEND;    /* Maximum pending SEND/SEOMs. */
  405.     unsigned char    maxDSND;    /* Maximum pending DSNDs. */
  406.     unsigned char    maxESND;    /* Maximum pending ESNDs. */
  407.     unsigned char    slot;        /* Slot number in 1000 hub. */
  408.     unsigned char    speed;        /* Line speed (MBytes/sec). */
  409.     unsigned char    adapterMaxBytes;/* Maximum packet size allowed by
  410.                      * adapter (as a power of 2). */
  411.     unsigned char    pad3[31];
  412. } NetUltraStartRequest;
  413.  
  414. /*
  415.  * Request format for a stop command.
  416.  */
  417. typedef struct NetUltraStopRequest {
  418.     NetUltraRequestHdr    hdr;        /* Request header. */
  419.     /*
  420.      * Nothing here. 
  421.      */
  422. } NetUltraStopRequest;
  423.  
  424.  
  425. /*
  426.  * Values for the flags field of a NetUltraStartRequest.
  427.  */
  428. #define NET_ULTRA_START_FLAGS_COPYDATA    1  /* Run in copydata mode, good
  429.                         * only for HSX adapters. */
  430. /* 
  431.  * Values for the hostType field of a NetUltraStartRequest.
  432.  */
  433.  
  434. #define NET_ULTRA_START_HOSTTYPE_FB        1  /* Ultra Frame Buffer. */
  435. #define NET_ULTRA_START_HOSTTYPE_CRAYXMP    2  /* Cray X-MP. */
  436. #define NET_ULTRA_START_HOSTTYPE_CRAY2        3  /* Cray 2 */
  437. #define NET_ULTRA_START_HOSTTYPE_ALL2        4  /* Alliant w/ 2 MB VME */
  438. #define NET_ULTRA_START_HOSTTYPE_ALL20        5  /* Alliant w/ 20 MB VME */
  439. #define NET_ULTRA_START_HOSTTYPE_CONVEX        6  /* Convex. */
  440. #define NET_ULTRA_START_HOSTTYPE_SUN        7  /* Sun. */
  441. #define NET_ULTRA_START_HOSTTYPE_IBM        8  /* Some sort of IBM */
  442. #define NET_ULTRA_START_HOSTTYPE_SGI        9  /* SGI Iris */
  443. #define NET_ULTRA_START_HOSTTYPE_MIPS        10 /* MIPS */
  444. #define NET_ULTRA_START_HOSTTYPE_UCRAY        11 /* MicroCray */
  445.  
  446. /*
  447.  * Values for the adapterType field of a NetUltraStartRequest.
  448.  */
  449.  
  450. #define NET_ULTRA_START_ADAPTYPE_HSX    1    /* HSX host adapter. */
  451. #define NET_ULTRA_START_ADAPTYPE_FB    2    /* Ultra Frame Buffer. */
  452. #define NET_ULTRA_START_ADAPTYPE_VME    3    /* VME host adapter. */
  453. #define NET_ULTRA_START_ADAPTYPE_LINK    4    /* Link adapter. */
  454. #define NET_ULTRA_START_ADAPTYPE_HSC    5    /* HSC host adapter. */
  455. #define NET_ULTRA_START_ADAPTYPE_LSX    6    /* LSX host adapter. */
  456. #define NET_ULTRA_START_ADAPTYPE_BMC    7    /* BMC host adapter. */
  457.  
  458. /*
  459.  * Union of all the different requests.
  460.  */
  461. typedef union {
  462.     NetUltraDatagramRequest    dgram;    /* Datagram request. */
  463.     NetUltraStartRequest    start;    /* Start request. */
  464.     NetUltraStopRequest        stop;    /* Stop request. */
  465. } NetUltraRequest;
  466.  
  467.  
  468. /*
  469.  * Format of the Request Blocks that are sent to the adapter. 
  470.  * These are referred to as XRBs (Transmitted Request Blocks) in the
  471.  * Ultranet documentation.  Note that there is an extra field (filled)
  472.  * at the beginning of our XRB.  The Ultranet source has an extra
  473.  * structure (rbqe) that is allocated in dma space and consists of their XRB and
  474.  * the filled flag.  The XRB is set up elsewhere and copied into the rbqe.
  475.  * We avoid that by putting the filled flag in the XRB itself.
  476.  */
  477.  
  478. typedef    struct NetUltraXRB{
  479.     Boolean        filled;    /* TRUE means the XRB has valid contents. */
  480.     NetUltraDMAInfo    dma;    /* The DMA information. */
  481.     NetUltraRequest    request; /* The request itself. */
  482. } NetUltraXRB;
  483.  
  484.  
  485. /*
  486.  * The following are a list of the opcodes for the various commands
  487.  * that can be sent to the Ultranet adapter.  The commands are different
  488.  * from the requests in that they are not enqueued.  The adapter is
  489.  * pointed at them directly and modifies their contents (when appropriate)
  490.  * directly.  In general the commands can only be sent after a reset
  491.  * (while in EPROM mode).
  492.  */
  493.  
  494. #define NET_ULTRA_INIT_OPCODE        1    /* Initialize */
  495. #define NET_ULTRA_LOAD_OPCODE        2    /* Load ucode. */
  496. #define NET_ULTRA_GO_OPCODE        3    /* Start execution. */
  497. #define NET_ULTRA_DIAG_OPCODE        6    /* Diagnostics. */
  498. #define NET_ULTRA_EXT_DIAG_OPCODE    7    /* Extended diagnostics. */
  499. #define NET_ULTRA_INFO_OPCODE        8    /* Get adapter info */
  500.  
  501. /*
  502.  * Command block for the initialization command. 
  503.  */
  504. typedef struct    NetUltraInitCommand {
  505.     int        opcode;        /*  NET_ULTRA_INIT_OPCODE*/
  506.     int        reply;        /* Returned by adapter. See below. */
  507.     int        version;    /* Adapter software version number. */
  508.     int        toAdapterAddr;    /* Queue of XRBs that are sent to the adapter.*/
  509.     int        toAdapterNum;    /* Number of elements in the queue. */
  510.     int        toHostAddr;    /* Queue of XRBs that are sent to the host.*/
  511.     int        toHostNum;    /* Number of elements in the queue. */
  512.     int        XRBSize;    /* Size of an XRB. */
  513.     char    priority;    /* Interrupt priority. */
  514.     char    vector;        /* Interrupt vector number. */
  515.     char    requestLevel;    /* VME bus request level. */
  516.     char    addressSpace;    /* VME address space for queues and buffers. */
  517.     char    pad[28];    /* Needs to be 64 bytes long. */
  518. } NetUltraInitCommand;
  519.  
  520. /*
  521.  * Values for the reply field of the NetUltraInitCommand.  The adapter
  522.  * sets this after it receives the init command.
  523.  */
  524.  
  525. #define NET_ULTRA_INIT_OK    1    /* Adapter initialized correctly. */
  526. #define NET_ULTRA_BAD_SIZE    2    /* The XRBSize is wrong. */
  527.  
  528. /*
  529.  * Command block for the diagnostic command. 
  530.  */
  531.  
  532. typedef struct NetUltraDiagCommand {
  533.     int    opcode;                /* NET_ULTRA_DIAG_OPCODE. */
  534.     int    reply;                /* Returned by adapter. See below. */
  535.     unsigned long     version;    /* Firmware version. */
  536.     unsigned long    error;        /* Error code. 0 if all tests passed,
  537.                      * number of test that failed 
  538.                      * otherwise. */
  539.     unsigned long    hwModel;    /* Hardware model. */
  540.     unsigned long    hwVersion;    /* Hardware version. */
  541.     unsigned long    hwRevision;    /* Hardware revision. */
  542.     unsigned long    hwOption;    /* Hardware option. */
  543.     unsigned long    hwSerial;    /* Hardware serial number. */
  544. } NetUltraDiagCommand;
  545.  
  546. /*
  547.  * Values for the reply field of the NetUltraDiagCommand.  The adapter
  548.  * sets this after it receives the command.
  549.  */
  550.  
  551. #define NET_ULTRA_DIAG_OK    1    /* Command completed ok. */
  552.  
  553.  
  554. /*
  555.  * Command block for the command to get the adapter info. For now this is
  556.  * the same structure as the diagnostic command (the difference between
  557.  * the two commands is that this one doesn't cause the diagnostics to
  558.  * be run.
  559.  */
  560.  
  561. typedef NetUltraDiagCommand NetUltraInfoCommand;
  562.  
  563. /*
  564.  * Values for the reply field of the NetUltraInfoCommand.  The adapter
  565.  * sets this after it receives the command.
  566.  */
  567.  
  568. #define NET_ULTRA_INFO_OK    1    /* Command completed ok. */
  569.  
  570. /*
  571.  * Command block for the Extended Diagnostics command. 
  572.  */
  573.  
  574. typedef struct NetUltraExtDiagCommand {
  575.     int            opcode;        /* NET_ULTRA_EXT_DIAG_OPCODE. */
  576.     int            reply;        /* Returned by adapter. See below. */
  577.     unsigned long    version;    /* Firmware version. */
  578.     unsigned long    error;        /* Error code. 0 if all tests passed,
  579.                      * otherwise the number of test that
  580.                      * failed. */ 
  581.     unsigned long    externalLoopback; /* 0 => do internal loopback,
  582.                      * otherwise do external loopback */
  583.     unsigned long    bufferAddress;    /* VME address of 8k buffer in which
  584.                      * to run tests. */
  585. } NetUltraExtDiagCommand;
  586.  
  587. /*
  588.  * Reply values for the NetUltraExtDiagCommand.
  589.  */
  590.  
  591. #define NET_ULTRA_EXT_DIAG_OK    1    /* Command completed ok. */
  592.  
  593. /*
  594.  * Size of the buffer for the extended diagnostics. 
  595.  */
  596.  
  597. #define NET_ULTRA_EXT_DIAG_BUF_SIZE     0x2000    /* 8KB. */
  598.  
  599. /*
  600.  * Command block for the command to download micro-code.
  601.  */
  602.  
  603. typedef struct NetUltraLoadCommand {
  604.     int            opcode;        /* NET_ULTRA_LOAD_OPCODE. */
  605.     int            reply;        /* Returned by adapter. See below. */
  606.     unsigned long    dataAddress;    /* VME address of the ucode data. */
  607.     unsigned long    loadAddress;    /* Address at which adapter should
  608.                      * load the ucode. */
  609.     unsigned long    length;        /* Length of the ucode data. */
  610.     char        *unused;    /* NOT USED. */
  611. } NetUltraLoadCommand;
  612.  
  613. /*
  614.  * Reply values for the NetUltraLoadCommand.
  615.  */
  616.  
  617. #define NET_ULTRA_LOAD_OK    1    /* Command completed ok. */
  618.  
  619. /*
  620.  * Command block for the go command.
  621.  */
  622.  
  623. typedef struct NetUltraGoCommand {
  624.     int            opcode;        /* NET_ULTRA_GO_OPCODE. */
  625.     int            reply;        /* Returned by adapter. See below. */
  626.     unsigned long    startAddress;    /* Start of execution. */
  627. } NetUltraGoCommand;
  628.  
  629. /*
  630.  * Reply values for the NetUltraGoCommand.
  631.  */
  632.  
  633. #define NET_ULTRA_GO_OK        1     /* Command completed ok. */
  634.  
  635. /*
  636.  * Amount of time (in microseconds) to wait for the adapter to reset. 
  637.  */
  638.  
  639. #define NET_ULTRA_RESET_DELAY 5 * 1000 * 1000
  640.  
  641. /*
  642.  * Amount of time (in microseconds) to wait for the adapter to process a
  643.  * command.
  644.  */
  645.  
  646.  
  647. #define NET_ULTRA_DELAY     15 * 1000 * 1000 /* Some things take a long time. */
  648.  
  649. /*
  650.  * General routines.
  651.  */
  652.  
  653. extern ReturnStatus NetUltraInit _ARGS_((Net_Interface *interPtr));
  654. extern void NetUltraIntr _ARGS_((Net_Interface *interPtr, Boolean polling));
  655. extern ReturnStatus NetUltraSendCmd _ARGS_((NetUltraState *statePtr, int ok, 
  656.             int size, Address cmdPtr));
  657. extern ReturnStatus NetUltraOutput _ARGS_((Net_Interface *interPtr, 
  658.             Address hdrPr, Net_ScatterGather *scatterGatherPtr, 
  659.             int scatterGatherLength, Boolean rpc, 
  660.             ReturnStatus *statusPtr));
  661. extern ReturnStatus NetUltraIOControl _ARGS_((Net_Interface *interPtr, 
  662.             Fs_IOCParam *ioctlPtr, Fs_IOReply *replyPtr));
  663. extern void Net_UltraReset _ARGS_((Net_Interface *interPtr));
  664. extern void Net_UltraHardReset _ARGS_((Net_Interface *interPtr));
  665. extern ReturnStatus NetUltraPendingRead _ARGS_((Net_Interface *interPtr, 
  666.             int size, Address buffer));
  667. extern ReturnStatus NetUltraInfo _ARGS_((NetUltraState *statePtr,
  668.             NetUltraInfoCommand *cmdPtr));
  669. extern ReturnStatus NetUltraExtDiag _ARGS_((NetUltraState *statePtr, 
  670.             Boolean external, char buffer[], 
  671.             NetUltraExtDiagCommand *cmdPtr));
  672. extern ReturnStatus NetUltraSendReq _ARGS_((NetUltraState *statePtr, 
  673.             void (*doneProc)(), ClientData data, 
  674.             Boolean rpc, int scatterLength,
  675.             Net_ScatterGather *scatterPtr, int requestSize, 
  676.             NetUltraRequest *requestPtr));
  677. #endif /* _NETULTRAINT */
  678.  
  679.